//
//  EPTabBarViewController.swift
//  EPHome
//
//  Created by liujianlong on 2022/8/1.
//

import UIKit

class EPTabBarViewController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.delegate = self
        self.setupColor()
        self.setupViewController()
    }
    func setupColor()
    {
        self.tabBar.isTranslucent = false
        self.tabBar.tintColor = HEX_BLUE2
        self.tabBar.unselectedItemTintColor = HEX_GRAY1
        self.tabBar.backgroundImage = UIImage.withColor(HEX_BG)
        self.tabBar.backgroundColor = HEX_BG
    }
    
    func setupViewController()
    {
        let controllers = [HomeViewController()]
        let titles = ["设备","商品","我的"]
        let imgs = ["设备","商品","我的"]
        let selectImgs = ["设备_选中","商品_选中","我的_选中"]
        for i in 0..<controllers.count{
            let vc = controllers[i]
            vc.tabBarItem = UITabBarItem()
            vc.tabBarItem.title = LS(titles[i])
            vc.tabBarItem.image = UIImage(named:imgs[i])?.withRenderingMode(.alwaysOriginal)
            vc.tabBarItem.selectedImage = UIImage(named:selectImgs[i])?.withRenderingMode(.alwaysOriginal)
            let nav = EPNavigationController(rootViewController:vc)
            //            nav.navigationBar.isHidden = true
            self.addChild(nav)
        }
    }
}

// MARK: - UITabBarControllerDelegate
extension EPTabBarViewController: UITabBarControllerDelegate
{
    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        return true
    }
}
